package com.example.demo.service.impl;

import com.example.demo.dao.StudentDao;
import com.example.demo.entity.StudentBean;
import com.example.demo.service.StudentService;
import com.example.demo.util.PageEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StudentServiceImpl implements StudentService {
    @Autowired
    private StudentDao studentDao;

    @Override
    public Integer add(StudentBean studentBean) {
        return studentDao.add(studentBean);
    }

    @Override
    public Integer update(StudentBean studentBean) {
        return studentDao.update(studentBean);
    }

    @Override
    public Integer delete(Integer id) {
        return studentDao.delete(id);
    }

    @Override
    public StudentBean one(Integer id) {
        return studentDao.getOneById(id);
    }

    @Override
    public PageEntity list(Integer pageNo, Integer pageSize, String name, String sortOrder) {
        Integer count = studentDao.count(name);
        List<StudentBean> list = studentDao.list(name, sortOrder);
        return new PageEntity<>(list, count);
    }
} 